﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

namespace Utility.BehaviourTree
{
	[HideFromCreateMenu]
	public class IfNode : DecoratorNode
	{
		Func<DataBoard, bool> condition;

		public IfNode (Func<DataBoard, bool> condition)
		{
			Debug.Assert (condition != null, "condition cannot be null");
			this.condition = condition;
		}

		protected override Status OnUpdate ()
		{
			if (condition (DataBoard))
			{
				return ChildNode.Update ();
			}
			else
			{
				return Status.Failure;
			}
		}
	}
}